import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

class UserPage extends StatefulWidget {
  const UserPage({super.key});

  @override
  State<UserPage> createState() => _UserPageState();
}

class _UserPageState extends State<UserPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
              onPressed: (){
                Get.bottomSheet(
                  Container(
                      height: 200,
                      color: Get.isDarkMode?Colors.black:Colors.white,
                      child: Column(
                        children: [
                          ListTile(
                            leading: Icon(Icons.wb_sunny_outlined,color: Get.isDarkMode?Colors.white:Colors.black),
                            title: Text('白天模式',style: TextStyle(color: Get.isDarkMode?Colors.white:Colors.black)),
                            onTap: (){
                              Get.changeTheme(
                                ThemeData(
                                  useMaterial3: true,
                                  colorScheme: ColorScheme.fromSeed(
                                    seedColor: Colors.blue, // 默认蓝色
                                    brightness: Brightness.light, // 默认浅色
                                  ),
                                  appBarTheme: AppBarTheme( // 默认深色
                                    backgroundColor: Colors.blue,
                                    foregroundColor: Colors.white,
                                    elevation: 0.0,// 阴影
                                  ),
                                ),
                              );
                              Get.back();
                            },
                          ),
                          ListTile(
                            leading: Icon(Icons.nights_stay_outlined,color: Get.isDarkMode?Colors.white:Colors.black),
                            title: Text('黑夜模式',style: TextStyle(color: Get.isDarkMode?Colors.white:Colors.black)),
                            onTap: (){
                              Get.changeTheme(
                                ThemeData(
                                  useMaterial3: true,
                                  colorScheme: ColorScheme.fromSeed(
                                    seedColor: Colors.black, // 默认蓝色
                                    brightness: Brightness.dark, // 默认浅色
                                  ),
                                  appBarTheme: AppBarTheme( // 默认深色
                                    backgroundColor: Colors.black,
                                    foregroundColor: Colors.white,
                                    elevation: 0.0,// 阴影
                                  ),
                                ),
                              );
                              Get.back();
                            },
                          ),
                        ],
                      )
                  ),
                );
                //Get.changeTheme(Get.isDarkMode ? ThemeData.light() : ThemeData.dark());
              },
              child: Text('切换主题'),
            ),
          ],
        )
      )
    );
  }
}
